#!/bin/bash

apt update

apt install docker.io
apt install docker-compose
alias dc=docker-compose

# 创建并配置daemon.json
mkdir -p /etc/docker
cat <<EOF > /etc/docker/daemon.json
{
  "registry-mirrors": [
    "https://docker.211678.top",
    "https://docker.1panel.live",
    "https://hub.rat.dev",
    "https://docker.m.daocloud.io",
    "https://do.nark.eu.org",
    "https://dockerpull.com",
    "https://dockerproxy.cn",
    "https://docker.awsl9527.cn"
  ],
  "data-root": "/data/docker",
  "log-driver":"json-file",
  "log-opts": {"max-size":"50m", "max-file":"3"}
}
EOF

# 创建数据目录
mkdir -p /data/docker

# 重启Docker使配置生效
systemctl restart docker

echo "Docker和Docker Compose安装完成，daemon.json配置已生效"